static-var  Open_1, Gun_2, Moving_3, Aiming_4, Busy_5, Req_State_6;
SmokeUnit(healthpercent, sleeptime, smoketype)

MotionControl(moving, aiming, justmoved)
	justmoved = TRUE;
	while( TRUE )
	{
		moving = Moving_3;
		aiming = Aiming_4;
		if( moving )
		{
			if( aiming )
			if( !aiming )
			{
				Busy_5 = 1;
			THEN
				Busy_5 = 0;
			}
			justmoved = TRUE;
		}
		if( !moving )
		{
			if( justmoved )
			{
				if( !aiming )
				{
				}
				justmoved = FALSE;
			}
			sleep 200;
		}
	}

RequestState()
	while( TRUE )
	{
			if( !Req_State_6 and Open_1 )
			{
				Open_1 = 0;
				Busy_5 = 1;
CLOSE!
				Aiming_4 = 0;
				Busy_5 = 0;
			}
			if( Req_State_6 and !Open_1 )
			{
				Busy_5 = 1;
OPEN!
				Open_1 = 1;
				Busy_5 = 0;
			}
		sleep 200;
	}
StartMoving()
	Moving_3 = 1;

StopMoving()
	Moving_3 = 0;

RestoreAfterDelay()
	sleep 10000;
	set-signal-mask 0;
	Req_State_6 = 0;

AimPrimary(heading, pitch)
	Aiming_4 = 1;
	while( Busy_5 )
	{
		sleep 300;
	}
	signal 2;
	set-signal-mask 0;
	set-signal-mask 2;
	Req_State_6 = 1;
	while( !Open_1 )
	{
		sleep 300;
		Req_State_6 = 1;
	}
	turn torso to y-axis heading speed <150>;
	wait-for-turn torso around y-axis;
	start-script RestoreAfterDelay();
	return (1);